export const getFileSize = num=>{
    
    // 小于1mb展示kb
    if(num<1024*1024){
        return (num/1024).toFixed(2)+'kb'
    }
    return (num/(1024*1024)).toFixed(2)+'mb'

}
// 计算两个数下降比例
export const getDecreaseRatio = (num1,num2)=>{
    return parseInt((num1-num2)/num2*100) + '%'
}

// 统计字符串
export const compressStr = (str)=>{
    if(str.length == '') return ''
    let newStr = ''
    let count = 1
    for(let i=1;i<str.length;i++){
        if(str[i] == str[i-1]){
            count++
        }else{
            newStr += str[i-1] + (count == 1 ? '':count)
            count = 1
        }
    }
    console.log(newStr)
    newStr += str[str.length-1] + count
    return newStr
}